<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>多边形</title>
    <style>
        .div1,.div2{
            width: 200px;
            height: 200px;
            transition:all 2s;
            margin: 150px auto;
        }
        .div1{
            background-color: #f00;
        }
        .div2{
            background-color: #0f0;
        }
        .div1:hover {
            transform:skew(45deg,0);
            transform-origin: left top;
        }
        /* .parallelograms{
            margin: 50px auto;
            max-width: 200px;
            padding: 10px;
            line-height: 30px;
            text-align: center;
            color:#fff;
            background-color: #58a;
            transform-origin: left top;
            transform:skew(-45deg);
        }
        .parallelograms div{
            transform: skew(45deg);
        } */
        .parallelograms{
            margin: 50px auto;
            max-width: 200px;
            padding: 10px;
            line-height: 30px;
            text-align: center;
            color:#fff;
            position: relative;
        }
        .parallelograms:before{
            content:'';
            position: absolute;
            left:0;
            top:0;
            right:0;
            bottom:0;
            background-color: #58a;
            transform:skew(-45deg);
            z-index: -1;
        }
        .diamod{
            width: 200px;
            height: 200px;
            overflow: hidden;
            transform: rotate(45deg);
            margin: 30px auto;
            border: 1px solid red; /*为了更好的展示问题*/
        }
        img{
            transform: rotate(-45deg) scale(1.42);
            max-width: 100%;
        }
        .diamod2{
            margin: 100px auto;
            width: 200px;
            height: 200px;
            overflow: hidden;
            position: relative;
            transform:rotate(45deg);
        }
        .diamod2::before{
            content:'';
            position:absolute;
            top:0;
            bottom: 0;
            left:0;
            right: 0;
            transform:rotate(-45deg) scale(1.42);
            background: url(https://avatars1.githubusercontent.com/u/8121621?v=4);
            background-size: cover;
        }
        .diamod3{
            width: 200px;
            height: 200px;
            border: 1px solid red;
            margin: 30px auto;
            background: url(https://avatars1.githubusercontent.com/u/8121621?v=4);
            clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
            background-size: cover;
            transform: scale(1.42);
        }
    </style>
</head>
<body>
    <div class="div1"></div>
    <div class="div2"></div>
    <div class="parallelograms">
        二十首情诗与绝望的歌d
    </div>

    <div class="diamod">
        <img src="https://avatars1.githubusercontent.com/u/8121621?v=4" alt="..." />
    </div>

    <div class="diamod2"></div>
    <div class="diamod3"></div>
</body>
</html>